package com.yiya.service;

import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yiya.bean.ExpenseType;
import com.yiya.mapper.ExpenseTypeMapper;
import com.yiya.model.ExpenseTypeModel;

@Service("ExpenseTypeService")
public class ExpenseTypeService {
	@SuppressWarnings("unused")
	private final static Logger log = Logger.getLogger(ExpenseTypeService.class);

	@Autowired
	private ExpenseTypeMapper expenseTypeMapper;
	
	public List<ExpenseType> queryByList(ExpenseTypeModel bean) {
		Integer rowCount = queryByCount(bean);
		bean.getPager().setRowCount(rowCount);
		List<ExpenseType> expenseTypes = expenseTypeMapper.selectByModel(bean);
		return expenseTypes;
	}
	
	public int queryByCount(ExpenseTypeModel bean){
		return expenseTypeMapper.countByModel(bean);
	}
	
	public int add(ExpenseType bean){
		return expenseTypeMapper.insert(bean);
	}
	
	public int Update(ExpenseType bean){
		return expenseTypeMapper.updateByPrimaryKeySelective(bean);
	}
	
	public ExpenseType queryById(Integer id){
		return expenseTypeMapper.selectByPrimaryKey(id);
	}
	
	public void delete(Integer[] ids){
		for(Integer id:ids){
			expenseTypeMapper.deleteByPrimaryKey(id);
		}
	}
	
	public List<ExpenseType> queryAllList(ExpenseTypeModel bean){
		return expenseTypeMapper.queryAllList(bean);
	}

}
